<!DOCTYPE html>
<html lang="zh">
<head>
  <meta charset="UTF-8">
  <title>位置显示地图</title>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link
    rel="stylesheet"
    href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css"
  />
  <style>
    html, body {
      margin: 0;
      padding: 0;
      height: 100%;
    }
    #map {
      width: 100%;
      height: 100%;
    }
  </style>
</head>
<body>
  <div id="map"></div>

  <script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
  <script>
    // 获取 URL 参数
    function getParam(name) {
      const url = new URL(location.href);
      return parseFloat(url.searchParams.get(name));
    }

    const lat = getParam('lat') || 31.2304;  // 默认上海
    const lng = getParam('lng') || 121.4737;

    // 初始化地图
    const map = L.map('map').setView([lat, lng], 16);

    // 加载 OpenStreetMap 图层
    L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
      maxZoom: 19
    }).addTo(map);

    // 添加标记
    L.marker([lat, lng]).addTo(map)
      .bindPopup("目标位置")
      .openPopup();
  </script>
</body>
</html>
